//获取窗口的宽度和高度
var winwidth = document.documentElement.clientWidth;
var winheight = document.documentElement.clientHeight;
//左则菜单的高度
var tcrmenu = document.getElementById("tcrmenu");
tcrmenu.style.height = winheight - 98 + 'px';
//手动界面的宽高
var jogContent = document.getElementById("jog_content");
jogContent.style.height = winheight - 100 + 'px';
jogContent.style.width = winwidth - 70 + 'px';
//图形界面的宽高
var programContent = document.getElementById("program_content");
programContent.style.height = winheight - 100 + 'px';
programContent.style.width = winwidth - 70 + 'px';
var blockdiv = document.getElementById("blocklyDiv");
blockdiv.style.height = winheight - 100 + 'px';
blockdiv.style.width = winwidth - 70 + 'px';
//数据界面的宽高
var ioContent = document.getElementById("io_content");
ioContent.style.height = winheight - 100 + 'px';
ioContent.style.width = winwidth - 70 + 'px';
var ioBox = document.getElementById("io_box");
ioBox.style.width = winwidth - 132 + 'px';
//消息界面的宽高
var messageContent = document.getElementById("message_content");
messageContent.style.height = winheight - 100 + 'px';
messageContent.style.width = winwidth - 70 + 'px';
//设置界面的宽高
var settingContent = document.getElementById("setting_content");
settingContent.style.height = winheight - 100 + 'px';
settingContent.style.width = winwidth - 70 + 'px';
//窗口旋转
window.onresize = function() {
	winwidth = document.documentElement.clientWidth;
	winheight = document.documentElement.clientHeight;
	tcrmenu.style.height = winheight - 98 + 'px';
	jogContent.style.height = winheight - 100 + 'px';
	jogContent.style.width = winwidth - 70 + 'px';
	programContent.style.height = winheight - 100 + 'px';
	programContent.style.width = winwidth - 70 + 'px';
	blockdiv.style.height = winheight - 100 + 'px';
	blockdiv.style.width = winwidth - 70 + 'px';
	ioContent.style.height = winheight - 100 + 'px';
	ioContent.style.width = winwidth - 70 + 'px';
	ioBox.style.width = winwidth - 132 + 'px';
	messageContent.style.height = winheight - 100 + 'px';
	messageContent.style.width = winwidth - 70 + 'px';
	settingContent.style.height = winheight - 100 + 'px';
	settingContent.style.width = winwidth - 70 + 'px';
}
//右上角菜单滑入滑出
var flag = false;
$("#menuswitch").on('click', function() {
	if(flag == false) {
		$(".downmenu").css('display', 'block');
		flag = true;
	} else {
		$(".downmenu").css('display', 'none');
		flag = false;
	}
	if(flag == true){
		setTimeout(function(){
			$(".downmenu").css('display', 'none');
			flag = false;
		},5000);
	}
});

//界面切换
//手动界面
$("#jogli").on('click', function() {
	$("#jog_content").css('z-index', '100');
	$("#program_content").css('z-index', '0');
	$("#io_content").css('z-index', '0');
	$("#message_content").css('z-index', '0');
	$("#setting_content").css('z-index', '0');
	$("#jogli img").attr('src', 'img/hand_green.png');
	$("#programli img").attr('src', 'img/route_white.png');
	$("#numberli img").attr('src', 'img/num_white.png');
	$("#messageli img").attr('src', 'img/message_white.png');
	$("#settingli img").attr('src', 'img/setting_white.png');
	$(".modal-dialog-bg").remove();
	$(".modal-dialog").remove();
});
//程序界面
$("#programli").on('click', function() {
	$("#jog_content").css('z-index', '0');
	$("#program_content").css('z-index', '100');
	$("#io_content").css('z-index', '0');
	$("#message_content").css('z-index', '0');
	$("#setting_content").css('z-index', '0');
	$("#jogli img").attr('src', 'img/hand_white.png');
	$("#programli img").attr('src', 'img/route_green.png');
	$("#numberli img").attr('src', 'img/num_white.png');
	$("#messageli img").attr('src', 'img/message_white.png');
	$("#settingli img").attr('src', 'img/setting_white.png');
});

//数据界面
$("#numberli").on('click', function() {
	$("#jog_content").css('z-index', '0');
	$("#program_content").css('z-index', '0');
	$("#io_content").css('z-index', '100');
	$("#message_content").css('z-index', '0');
	$("#setting_content").css('z-index', '0');
	$("#jogli img").attr('src', 'img/hand_white.png');
	$("#programli img").attr('src', 'img/route_white.png');
	$("#numberli img").attr('src', 'img/num_green.png');
	$("#messageli img").attr('src', 'img/message_white.png');
	$("#settingli img").attr('src', 'img/setting_white.png');
	$(".modal-dialog-bg").remove();
	$(".modal-dialog").remove();
});
//消息界面
$("#messageli").on('click', function() {
	$("#jog_content").css('z-index', '0');
	$("#program_content").css('z-index', '0');
	$("#io_content").css('z-index', '0');
	$("#message_content").css('z-index', '100');
	$("#setting_content").css('z-index', '0');
	$("#jogli img").attr('src', 'img/hand_white.png');
	$("#programli img").attr('src', 'img/route_white.png');
	$("#numberli img").attr('src', 'img/num_white.png');
	$("#messageli img").attr('src', 'img/message_green.png');
	$("#settingli img").attr('src', 'img/setting_white.png');
	$(".modal-dialog-bg").remove();
	$(".modal-dialog").remove();
});
//设置界面
$("#settingli").on('click', function() {
	$("#jog_content").css('z-index', '0');
	$("#program_content").css('z-index', '0');
	$("#io_content").css('z-index', '0');
	$("#message_content").css('z-index', '0');
	$("#setting_content").css('z-index', '100');
	$("#jogli img").attr('src', 'img/hand_white.png');
	$("#programli img").attr('src', 'img/route_white.png');
	$("#numberli img").attr('src', 'img/num_white.png');
	$("#messageli img").attr('src', 'img/message_white.png');
	$("#settingli img").attr('src', 'img/setting_green.png');
	$(".modal-dialog-bg").remove();
	$(".modal-dialog").remove();
});
